package com.starpl.mobile.android.monthunsae.november.common;

import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;

import com.starpl.mobile.android.monthunsae.november.R;
import com.starpl.mobile.android.monthunsae.november.activity.AddCommunityActivity;
import com.starpl.mobile.android.monthunsae.november.activity.CommentActivity;
import com.starpl.mobile.android.monthunsae.november.activity.HomeActivity;
import com.starpl.mobile.android.monthunsae.november.activity.MessageActivity;
import com.starpl.mobile.android.monthunsae.november.activity.SettingActivity;
import com.starpl.mobile.android.platform.common.ActivityUtil;
import com.starpl.mobile.android.platform.common.base.BaseOptionMenu;

/**
 * 기본 옵션 메뉴 구현부
 * 
 * @author 박우람
 * @since 2011.03.17
 */
public class MonthUnsaeOptionMenu implements BaseOptionMenu
{
	private static final int OPTION_MENU_HOME = 0;
	private static final int OPTION_MENU_COMMENT = 1;
	private static final int OPTION_MENU_MESSAGE = 2;
	private static final int OPTION_MENU_ADD_COMMUNITY = 3;
	private static final int OPTION_MENU_SETTING = 4;
	private static final int OPTION_MENU_LOGOUT = 5;
	
	private Activity mParentActivity;
	
	/* (non-Javadoc)
	 * @see com.starpl.platform.common.base.BaseOptionMenu#onCreateOptionMenu(com.starpl.platform.common.base.BaseActivity, android.view.Menu)
	 */
	@Override
	public void onCreateOptionMenu(Activity activity, Menu menu)
	{
		menu.addSubMenu(0, OPTION_MENU_HOME, 0, "홈").setIcon(R.drawable.icon_menu_home);
		menu.addSubMenu(0, OPTION_MENU_COMMENT, 0, "댓글").setIcon(R.drawable.icon_menu_reply);
		menu.addSubMenu(0, OPTION_MENU_MESSAGE, 0, "쪽지").setIcon(R.drawable.icon_menu_message);
		menu.addSubMenu(0, OPTION_MENU_ADD_COMMUNITY, 0, "커뮤니티추가").setIcon(R.drawable.icon_menu_add);
		menu.addSubMenu(0, OPTION_MENU_SETTING, 0, "설정").setIcon(R.drawable.icon_menu_setting);
		menu.addSubMenu(0, OPTION_MENU_LOGOUT, 0, "로그아웃").setIcon(R.drawable.icon_menu_logout);
		
		mParentActivity = activity;
	}

	/* (non-Javadoc)
	 * @see com.starpl.platform.common.base.BaseOptionMenu#onOptionsItemSelected(android.view.MenuItem)
	 */
	@Override
	public void onOptionsItemSelected(MenuItem item)
	{
		switch(item.getItemId())
		{
		// 홈으로 이동
		case OPTION_MENU_HOME:
			new ActivityUtil(mParentActivity)
				.setTargetActivity(HomeActivity.class)
				.setRemoveToActivity(HomeActivity.class)
				.show();
			break;
			
		// 댓글로 이동
		case OPTION_MENU_COMMENT:
			new ActivityUtil(mParentActivity)
				.setTargetActivity(CommentActivity.class)
				.setRemoveToActivity(HomeActivity.class)
				.show();
			break;
			
		// 쪽지로 이동
		case OPTION_MENU_MESSAGE:
			new ActivityUtil(mParentActivity)
				.setTargetActivity(MessageActivity.class)
				.setRemoveToActivity(HomeActivity.class)
				.show();
			break;
			
		// 계획 추가로 이동
		case OPTION_MENU_ADD_COMMUNITY:
			new ActivityUtil(mParentActivity)
				.setTargetActivity(AddCommunityActivity.class)
				.setRemoveToActivity(HomeActivity.class)
				.show();
			break;
			
		// 설정으로 이동
		case OPTION_MENU_SETTING:
			new ActivityUtil(mParentActivity)
				.setTargetActivity(SettingActivity.class)
				.setRemoveToActivity(HomeActivity.class)
				.show();
			break;
			
		// 로그아웃
		case OPTION_MENU_LOGOUT:
			LoginUtil.logoutUser(mParentActivity);
			break;
		}
	}
}